The position vector of a point in space depends on how you define your coordinate system.
Suppose that one coordinate system $S$ defined by $(x,y,z)$ is fixed at the origin. Suppose that a second coordinate system $S_0$ is defined by axes labeled $(x_0,y_0,z_0)$ with origin at the location $\Delta \vec{r}$ relative to the first frame.
A particle is at the location $\vec{r}$ relative to the fixed frame. Relative to the second frame, its location is $\vec{r}_0$. These vectors are related according to
$$\vec{r}=\Delta \vec{r} + \vec{r}_0.$$Suppose that the first frame $S$ is at the origin (or defines the origin). The second frame $S_0$ is aligned with the first frame and is at the location $<1.1,0,0>$ m. An object is at $\vec{r}=<2,0.5,0>$ m relative to the first frame. What is the object's position relative to the second frame, $\vec{r}_0$? Sketch the two frames, sketch $\vec{r}$ and $\vec{r}_0$.
In [1]:
#import packages
from __future__ import division, print_function
from ivisual import *
In [2]:
#create the scene
scene = canvas(title='Linear Coordinate Transformation')
#draw first coordinate system
L=1
sw=L/50
xaxis=arrow(pos=(-L/2,0,0), axis=(L,0,0), shaftwidth=sw)
yaxis=arrow(pos=(0,-L/2,0), axis=(0,L,0), shaftwidth=sw)
zaxis=arrow(pos=(0,0,-L/2), axis=(0,0,L), shaftwidth=sw)
#dr is the position of the second coordinate system relative to the first
dr=1.1*vector(1,0,0)
drarrow=arrow(pos=(0,0,0),axis=dr, shaftwidth=2*sw, fixedwidth=True, color=color.green)
#draw second coordinate system
xaxis0=arrow(pos=vector(-L/2,0,0)+dr, axis=(L,0,0), shaftwidth=sw, color=color.yellow)
yaxis0=arrow(pos=vector(0,-L/2,0)+dr, axis=(0,L,0), shaftwidth=sw, color=color.yellow)
zaxis0=arrow(pos=vector(0,0,-L/2)+dr, axis=(0,0,L), shaftwidth=sw, color=color.yellow)
#draw a particle at position r and draw the position vector r
r=vector(2,0.5,0)
R=0.1
particle=sphere(pos=r, radius=R, color=color.magenta)
rarrow=arrow(pos=(0,0,0), axis=r, shaftwidth=2*sw, color=color.cyan)
#calculate the position of the particle in the second coordinate system
r0=r-dr
#draw the position vector r0 for second coordinate system
r0arrow=arrow(pos=dr, axis=r0, shaftwidth=2*sw, color=color.blue)
Suppose that the second reference frame is moving with constant velocity $\vec{V}$ and starts with its origin aligned with the first reference frame at $t=0$. Then the origin of the moving frame, relative to the fixed frame, is at the location
$$\Delta \vec{r}= \vec{V}\Delta t$$and the position of the particle in the fixed frame is
$$\vec{r}=\vec{r}_0 + \vec{V}\Delta t.$$Suppose that the moving reference frame has a velocity $\vec{V}=<2,0,0>$ m/s, and the particle is at rest. What is the velocity of the particle relative to the moving reference frame?
Let's write a program to show how the vector $\vec{r}_0$ changes. If we print the vector $\vec{r}_0$ at each clock reading $t$, then we can study the motion of the particle as measured in the reference frame $S_0$.
Note that when executing the cell below, the scene above will begin changing. To slow it down in order to give you time to scroll up, and see the animation, I put a while loop that counted to 5 in 1 second intervals. Thus, it delays 5 second.
In [3]:
#make a list for the 0 coord sys axes
S0coordsys=[xaxis0,yaxis0,zaxis0]
#place moving frame at the origin and update arrows
dr=vector(0,0,0)
#update 0 coord sys
xaxis0.pos=vector(-L/2,0,0)+dr
yaxis0.pos=vector(0,-L/2,0)+dr
zaxis0.pos=vector(0,0,-L/2)+dr
#update arrows
drarrow.axis=dr
r0=r-dr
r0arrow.pos=dr
r0arrow.axis=r0
#define the velocity of the moving frame
V=vector(2,0,0)
t=0
dt=0.01
#fix the size if the window
scene.range=3
scene.autoscale=0
#delay
N=5 #seconds
n=0
while n<N:
rate(1)#1 second delay
n=n+1
#print header
print("r_0 vector (m)", "\t", "t (s)")
print(r0,"\t",t)
#move the S0 coord system and update vectors
while t<1.5:
rate(20)
#update S0 coord sys
for axis in S0coordsys:
axis.pos=axis.pos+V*dt
#update vectors
dr=dr+V*dt
drarrow.axis=dr
r0=r-dr
r0arrow.pos=xaxis0.pos+0.5*xaxis0.axis
r0arrow.axis=r0
t=t+dt
print(r0,t)
In frame $S$, the particle is at rest. By examining the data, what is the velocity of the particle as measured in frame $S_0$?
It would be nice to graph the data. To do this, we should store the data in lists and use the matplotlib package.
In [8]:
#reset r, r0, and dr; although r didn't change since the particle is at rest it's good practice
r=vector(2,0.5,0)
dr=vector(0,0,0)
r0=r-dr
#reset clock
t=0
#create lists to store data
tlist=[]
xlist=[]
tlist.append(t)
xlist.append(r0.x)
#move the S0 frame and calculate r0
#there's no need to animate, so we won't update arrows
while t<1.5:
#update vectors
dr=dr+V*dt
r0=r-dr
t=t+dt
tlist.append(t)
xlist.append(r0.x)
print(xlist,tlist)
Now we need to import matplotlib and graph the data. The "%matplotlib inline" magic command in Notebook causes the graph to be displayed within the page. Without this command, the graph will be displayed in a pop-up window.
In [9]:
%matplotlib inline
In [10]:
import matplotlib.pyplot as plt
In [11]:
plt.title('x vs t')
plt.xlabel('time (s)')
plt.ylabel('x (m)')
plt.plot(tlist, xlist, 'b.')
plt.show()
How would a scientist in the moving frame $S_0$ describe the motion of the particle?
In [ ]: